/**
 * <p>Title: ExpcetionHandle.java</p>
 * <p>Description: </p> 
 * @author xuchang 
 * @date 2018年8月12日
 */
package com.bclz.config;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bclz.common.response.ResponseData;
import com.bclz.common.response.ResponseUtils;

import ch.qos.logback.classic.Logger;

/**  
* Title: ExpcetionHandle  
* Description: 异常处理 
* @author xuchang  
* @date 2018年8月12日  
*/

@ControllerAdvice
public class ExpcetionHandle {
	
	private Logger log=(Logger)LoggerFactory.getLogger(getClass());
	
	@ExceptionHandler(value={Exception.class,RuntimeException.class})
	@ResponseBody
	public ResponseData handleException(HttpServletRequest re,Exception e) {
		
		log.error("{} \n Url:{} occured 500",e.getMessage(),re.getRequestURI());
		return ResponseUtils.fail("服务器异常", null);
		
	}
}
